/*
  Copyright(c) 2007-08 Cliff Hall <clifford.hall@puremvc.org>
  Your reuse is governed by the Creative Commons Attribution 3.0 License
 */
package com
{
	import com.controller.StartupCommand;
	import org.puremvc.as3.multicore.patterns.facade.Facade;
	
	public class ApplicationFacade extends Facade
	{
		public static const STARTUP:String				= "startup";
		public static const VALIDATE_FORMS:String		= "validateForms";
		public static const RESET_FORMS:String			= "resetForms";
		
		/**************************STATE MACHINE************************************/
		public static const WELCOMING:String			= "state/welcoming";
		public static const COLLECTING:String			= "state/collecting";
		public static const VALIDATING:String			= "state/validating";
		public static const SAVING:String				= "state/saving";
		public static const FAILING:String				= "state/failing";
		public static const THANKING:String				= "state/thanking";
		
		public static const COLLECT:String				= "actions/collect";
		public static const SUBMITED:String				= "actions/submited";
		public static const VALIDATED:String			= "actions/validated";
		public static const SAVED:String				= "actions/saved";
		public static const FAILED:String				= "actions/failed";
		public static const LOGOUT:String				= "actions/logout";
		
		public static const ENTER_COLLECTING:String		= "enter/collecting";
		public static const CONFIRM_LOGOUT:String		= "exit/confirm_logout";
		
		public static const SHOW_WELCOME:String			= "changed/show_welcome";
		public static const SAVE_FORM:String			= "changed/save_form";
		public static const SHOW_THANKS:String			= "changed/show_thanks";
		public static const SHOW_FAILED:String			= "changed/show_failed";
		/**************************STATE MACHINE************************************/
		
		public function ApplicationFacade( key:String )
	 	{
	 		super(key);	
	 	}
      	public static function getInstance( key:String ) : ApplicationFacade 
        {
            if ( instanceMap[ key ] == null ) instanceMap[ key ]  = new ApplicationFacade( key );
            return instanceMap[ key ] as ApplicationFacade;
        }
		public function startup ( app:PureFormSubmission ) : void
		{
			sendNotification( STARTUP, app );
		}
		override protected function initializeController () : void
		{
			super.initializeController();
			registerCommand( STARTUP, StartupCommand );
		}
	}
}